package com.hwl.server.controller;


import com.hwl.server.entity.Department;
import com.hwl.server.pojo.RespBean;
import com.hwl.server.service.DepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author long
 * @since 2021-11-28
 */
@Api(tags = "DepartmentController")
@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {

    @Resource
    private DepartmentService departmentService;

    @ApiOperation("获取所有部门")
    @GetMapping("/")
    public List<Department> getAllDepartments() {
        return departmentService.getAllDepartments();
    }

    @ApiOperation("添加部门")
    @PostMapping("/")
    public RespBean addDepartment(@RequestBody Department department) {
        return departmentService.addDep(department);
    }

    @ApiOperation("删除部门")
    @DeleteMapping("/{id}")
    public RespBean delDepartment(@PathVariable Integer id) {
        return departmentService.deleteDep(id);
    }
}
